package com.tastesport.chat.controller;


import com.tastesport.chat.model.user.LoginCriteria;
//import com.tastesport.chat.model.user.User;

import com.tastesport.chat.service.UserService;
import com.tastesport.chat.util.response.ResponseObj;
import org.jim.common.packets.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public ResponseObj login(@RequestBody LoginCriteria loginCriteria, HttpServletRequest Request) throws Exception {
        String username = loginCriteria.getName();
        User user = userService.checkLogin(username);
        Map<String, Object> map = new HashMap<>();
        map.put("user", user);
        return ResponseObj.createSuccessResponse(map);
    }

}
